$(function(){
	var url = path + "/sellServlet";
	//键盘抬起时，回显出商品名称，价格，类别，
	//当不存在该商品时，提示输入错误
	$("input[name='proid']").blur(function(){
		// 通过jQuery选择器获得name属性值为proid的input元素
		var proid = $(this).val();
		$.ajax({
			url:path + '/sellServlet',
			type:'post',
			data:{
				proid:proid, 
				method:"check"
			},
			dataType:"json",
			success:function(data){
					var production_type = data.production_type;
					var production_name = data.production_name;
					var PRODUCTION_PRICE = data.PRODUCTION_PRICE;
				    

					$("input[name='proType']").val(production_type);
					$("input[name='proName']").val(production_name);
					$("input[name='proPrice']").val(PRODUCTION_PRICE);
				} 
		})
	})
	
	$("input[name='phoneNum']").blur(function(){
		var phoneNum = $(this).val();
		$.ajax({
			url:path + "/sellServlet",
			data:{
				phoneNum:phoneNum,
				method: "selectVip"
			},
			type:"post",
			dataType:"json",
			success:function(data){
				//从jsp中获得数值
				var a = document.getElementById(proNum);
				var b = document.getElementById(proPrice);
			  console.log("打印出来了吗"+a);
			  console.log(b);
				if(data == "true"){ //客户为vip客户
					var sum = a*b*0.8;
					console.log(sum);
					$("input[name='proSumPrice']").val(sum);
				}else{
					var sum = a*b;
					$("input[name='proSumPrice']").val(sum);

				}
				
			},
			error:function(arg1,arg2,arg3){
				
			}
		})
	})

	$("input[name='proType']").val(data.production_type);
	$("input[name='proName']").val(data.production_name);
	$("input[name='proPrice']").val(data.PRODUCTION_PRICE);
})

/*$(function(){
	var url = path + "/sellServlet";
	
})*/


					